home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 1 / Mac Magazin and MacEasy Magazine CD - Issue 01.iso / Sharewarebibliothek / Powermac / C64 / SOURCE / NewInstructions.h < prev    next >
Text File  |  1994-06-06  |  8KB  |  295 lines

  1. #define FlagsNZ(z)\
  2.     flags &=~(ZER+NEG); if (z==0) flags|=ZER; else flags |=z&128
  3.  
  4. #define ORA(x) a|=ByteAt(x()); FlagsNZ(a)
  5. #define ASL(x) \
  6.     addr = x();\
  7.     tbyte = ByteAt(addr);\
  8.     flags &=~(CAR+NEG+ZER);\
  9.     if (tbyte&128) flags |= CAR;\
  10.     if (tbyte=tbyte<<1) flags |=tbyte&128; else flags |=ZER;\
  11.     RAM[addr] = tbyte; \
  12.     if (addr==1) \
  13.         if (tbyte!=oldMemoryMap) \
  14.             { \
  15.                 oldMemoryMap=tbyte; \
  16.                 SetUpMemoryMap(); \
  17.             }
  18. #define LSR(x) \
  19.     addr=x();\
  20.     tbyte=ByteAt(addr);\
  21.     flags &=~(CAR+NEG+ZER);\
  22.     flags |=tbyte&1;\
  23.     if (tbyte=tbyte>>1); else flags |=ZER;\
  24.     RAM[addr] = tbyte; \
  25.     if (addr==1) \
  26.         if (tbyte!=oldMemoryMap) \
  27.             { \
  28.                 oldMemoryMap=tbyte; \
  29.                 SetUpMemoryMap(); \
  30.             }
  31. #define BCL(x) \
  32.     if (flags&x) pc++; \
  33.     else {\
  34.         tbyte=ImmediateByte();\
  35.         pc++;\
  36.         if (tbyte&128) pc-=(tbyte^255)+1; \
  37.         else pc +=tbyte; }
  38. #define BST(x) \
  39.     if (flags&x) {\
  40.         tbyte=ImmediateByte();\
  41.         pc++;\
  42.         if (tbyte&128) pc-=(tbyte^255)+1;\
  43.         else pc +=tbyte; }\
  44.     else pc++;
  45. #define CLR(x) flags &=~x;
  46. #define SET(x) flags |= x;
  47. #define AND(x) a &= ByteAt(x()); FlagsNZ(a)
  48. #define BIT(x) \
  49.     tbyte=ByteAt(x());\
  50.     flags &=~(ZER+NEG+OVF);\
  51.     if ((a&tbyte)==0) flags |=ZER;\
  52.     flags |=tbyte&(128+64)
  53. #define ROL(x) \
  54.     addr=x();\
  55.     tbyte=ByteAt(addr);\
  56.     if (flags&CAR) {\
  57.         if (tbyte&128);\
  58.         else flags &=~CAR;\
  59.         tbyte=(tbyte<<1)|1; }\
  60.     else {\
  61.         if (tbyte&128) flags|=CAR;\
  62.         tbyte=tbyte<<1; }\
  63.     FlagsNZ(tbyte);\
  64.     RAM[addr] = tbyte; \
  65.     if (addr==1) \
  66.         if (tbyte!=oldMemoryMap) \
  67.             { \
  68.                 oldMemoryMap=tbyte; \
  69.                 SetUpMemoryMap(); \
  70.             }
  71. #define EOR(x)     a^=ByteAt(x());FlagsNZ(a)
  72. #define ADC(x) \
  73.     addr=ByteAt(x());\
  74.     if (flags&DEC) {\
  75.         addr = bcd2dec[addr]+bcd2dec[a]+((flags&CAR)?1:0);\
  76.         flags &= ~(CAR+OVF+NEG+ZER);\
  77.         if (addr>99) {flags|=CAR+OVF;addr -=100;}\
  78.         if (addr==0) flags|=ZER; else flags |=addr&128;\
  79.         a=dec2bcd[addr];}\
  80.     else {\
  81.         addr += a+((flags&CAR)?1:0);\
  82.         flags &= ~(CAR+OVF+NEG+ZER);\
  83.         if (addr>255) {flags|=OVF+CAR; addr &=255;}\
  84.         if (addr==0) flags|=ZER; else flags |=addr&128;\
  85.         a=addr;}
  86. #define ROR(x) \
  87.     addr=x(); tbyte=ByteAt(addr);\
  88.     if(flags&CAR){if(tbyte&1); else flags&=~CAR;tbyte=(tbyte>>1)|128;}\
  89.     else{if(tbyte&1) flags|=CAR;tbyte=tbyte>>1;}\
  90.     FlagsNZ(tbyte);\
  91.     RAM[addr] = tbyte; \
  92.     if (addr==1) \
  93.         if (tbyte!=oldMemoryMap) \
  94.             { \
  95.                 oldMemoryMap=tbyte; \
  96.                 SetUpMemoryMap(); \
  97.             }
  98. #define STA(x) RAM[addr=x()]=a; \
  99.     if (addr==1) \
  100.         if (a!=oldMemoryMap) \
  101.             { \
  102.                 oldMemoryMap=a; \
  103.                 SetUpMemoryMap(); \
  104.             }
  105.  
  106. #define STY(x) RAM[addr=x()]=y;\
  107.     if (addr==1) \
  108.         if (y!=oldMemoryMap) \
  109.             { \
  110.                 oldMemoryMap=y; \
  111.                 SetUpMemoryMap(); \
  112.             }
  113.  
  114. #define STX(y) RAM[addr=y()]=x;\
  115.     if (addr==1) \
  116.         if (x!=oldMemoryMap) \
  117.             { \
  118.                 oldMemoryMap=x; \
  119.                 SetUpMemoryMap(); \
  120.             }
  121.  
  122. #define CPY(x) \
  123.     tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
  124.     if (y==tbyte) flags |=CAR+ZER;\
  125.     else if (y>tbyte) flags |=CAR;\
  126.         else flags |=NEG
  127. #define CPX(y) \
  128.     tbyte=ByteAt(y()); flags &=~(CAR+ZER+NEG);\
  129.     if (x==tbyte) flags |=CAR+ZER;\
  130.     else if (x>tbyte) flags |=CAR;\
  131.         else flags |=NEG
  132. #define CMP(x) \
  133.     tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
  134.     if (a==tbyte) flags |=CAR+ZER;\
  135.     else if (a>tbyte) flags |=CAR;\
  136.         else flags |=NEG
  137. #define SBC(x) \
  138.     addr=ByteAt(x());\
  139.     if (flags&DEC) {\
  140.         addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
  141.         flags &= ~(CAR+ZER+NEG+OVF);\
  142.         if (addr==0) flags |=ZER+CAR;\
  143.         else if (((int)addr)>0) flags |=CAR;\
  144.             else {flags|=NEG; addr +=100;}\
  145.         a=dec2bcd[addr];}\
  146.     else {\
  147.         addr = a-addr-((flags&CAR)?0:1);\
  148.         flags &=~(CAR+ZER+OVF+NEG);\
  149.         if (addr==0) flags |=ZER+CAR;\
  150.         else if (((int)addr)>0) flags |=CAR;\
  151.             else flags|=OVF;\
  152.         flags |=addr&128;\
  153.         a=addr&255;}
  154. #define DECR(x) \
  155.     addr=x(); tbyte=ByteAt(addr);\
  156.     flags &=~(ZER+NEG);\
  157.     if (--tbyte) flags |=tbyte&128; else flags|=ZER;\
  158.     RAM[addr] = tbyte; \
  159.     if (addr==1) \
  160.         if (tbyte!=oldMemoryMap) \
  161.             { \
  162.                 oldMemoryMap=tbyte; \
  163.                 SetUpMemoryMap(); \
  164.             }
  165. #define INCR(x) \
  166.     addr=x(); tbyte=ByteAt(addr);\
  167.     flags &=~(ZER+NEG);\
  168.     if (++tbyte) flags |=tbyte&128; else flags|=ZER;\
  169.     RAM[addr] = tbyte; \
  170.     if (addr==1) \
  171.         if (tbyte!=oldMemoryMap) \
  172.             { \
  173.                 oldMemoryMap=tbyte; \
  174.                 SetUpMemoryMap(); \
  175.             }
  176. #define LDA(x) a=ByteAt(x()); FlagsNZ(a)
  177. #define LDY(x) y=ByteAt(x()); FlagsNZ(y)
  178. #define LDX(y) x=ByteAt(y()); FlagsNZ(x)
  179.  
  180. /*  UNDOCUMENTED OPCODES */
  181. #define AAX(y) \
  182.     addr=y(); tbyte=a&x; RAM[addr]=tbyte;FlagsNZ(tbyte);
  183. #define AMA() \
  184.     tbyte=ImmediateByte(); a=a&tbyte&0x11; FlagsNZ(a);
  185. #define ANA() \
  186.     tbyte=ImmediateByte(); a=a&tbyte;FlagsNZ(a);\
  187.     if(a&128) flags|=CAR;else flags&=~CAR;
  188. #define AXM() \
  189.     a=a&x;\
  190.     addr=ImmediateByte();\
  191.     if (flags&DEC) {\
  192.         addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
  193.         flags &= ~(CAR+ZER+NEG+OVF);\
  194.         if (addr==0) flags |=ZER+CAR;\
  195.         else if (((int)addr)>0) flags |=CAR;\
  196.             else {flags|=NEG; addr +=100;}\
  197.         a=dec2bcd[addr];}\
  198.     else {\
  199.         addr = a-addr-((flags&CAR)?0:1);\
  200.         flags &=~(CAR+ZER+OVF+NEG);\
  201.         if (addr==0) flags |=ZER+CAR;\
  202.         else if (((int)addr)>0) flags |=CAR;\
  203.             else flags|=OVF;\
  204.         flags |=addr&128;\
  205.         a=addr&255;}
  206. #define AXS(y) \
  207.     sp=a&x;FlagsNZ(sp);\
  208.     RAM[y()]=sp&0x11;
  209. #define CRS()
  210. #define DCP(x) \
  211.     addr=x(); tbyte=RAM[addr]=ByteAt(addr)-1; \
  212.     flags &=~(CAR+ZER+NEG);\
  213.     if ((a-tbyte)==tbyte) flags |=CAR+ZER;\
  214.     else if ((a-tbyte)>tbyte) flags |=CAR;\
  215.         else flags |=NEG
  216. #define ISB(x) \
  217.     addr=x(); tbyte=RAM[addr]=ByteAt(addr)-1; \
  218.     addr=tbyte;\
  219.     if (flags&DEC) {\
  220.         addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
  221.         flags &= ~(CAR+ZER+NEG+OVF);\
  222.         if (addr==0) flags |=ZER+CAR;\
  223.         else if (((int)addr)>0) flags |=CAR;\
  224.             else {flags|=NEG; addr +=100;}\
  225.         a=dec2bcd[addr];}\
  226.     else {\
  227.         addr = a-addr-((flags&CAR)?0:1);\
  228.         flags &=~(CAR+ZER+OVF+NEG);\
  229.         if (addr==0) flags |=ZER+CAR;\
  230.         else if (((int)addr)>0) flags |=CAR;\
  231.             else flags|=OVF;\
  232.         flags |=addr&128;\
  233.         a=addr&255;}
  234. #define LAN(x) \
  235.     addr=x();\
  236.     tbyte=ByteAt(addr);\
  237.     if (flags&CAR) {\
  238.         if (tbyte&128);\
  239.         else flags &=~CAR;\
  240.         tbyte=(tbyte<<1)|1; }\
  241.     else {\
  242.         if (tbyte&128) flags|=CAR;\
  243.         tbyte=tbyte<<1; }\
  244.     a&=tbyte; FlagsNZ(a);
  245. #define LAS(y) \
  246.     a=x=sp=ByteAt(y()); FlagsNZ(a);
  247. #define LAX(y) \
  248.     a=x=ByteAt(y());FlagsNZ(a);
  249. #define LOR(x) \
  250.     addr=x(); tbyte=ByteAt(addr);if (tbyte&1) flags|=CAR;else flags&=~CAR;\
  251.     tbyte=tbyte>>1; RAM[addr]=tbyte; a|=tbyte; FlagsNZ(a);
  252. #define RAD(x) \
  253.     addr=x();\
  254.     tbyte=ByteAt(addr);\
  255.     if (flags&CAR) {\
  256.         if (tbyte&128);\
  257.         else flags &=~CAR;\
  258.         tbyte=(tbyte<<1)|1; }\
  259.     else {\
  260.         if (tbyte&128) flags|=CAR;\
  261.         tbyte=tbyte<<1; }\
  262.     addr=tbyte;\
  263.     if (flags&DEC) {\
  264.         addr = bcd2dec[addr]+bcd2dec[a]+((flags&CAR)?1:0);\
  265.         flags &= ~(CAR+OVF+NEG+ZER);\
  266.         if (addr>99) {flags|=CAR+OVF;addr -=100;}\
  267.         if (addr==0) flags|=ZER; else flags |=addr&128;\
  268.         a=dec2bcd[addr];}\
  269.     else {\
  270.         addr += a+((flags&CAR)?1:0);\
  271.         flags &= ~(CAR+OVF+NEG+ZER);\
  272.         if (addr>255) {flags|=OVF+CAR; addr &=255;}\
  273.         if (addr==0) flags|=ZER; else flags |=addr&128;\
  274.         a=addr;}
  275. #define RMAM() \
  276.     a&=ImmediateByte();\
  277.     if(flags&CAR){if(a&1); else flags&=~CAR;a=(a>>1)|128;}\
  278.     else{if(a&1) flags|=CAR;a=a>>1;}\
  279.     FlagsNZ(a);
  280. #define RBM() \
  281.     a&=ImmediateByte();\
  282.     if(a&1)flags|=CAR;else flags&=~CAR;a=a>>1;FlagsNZ(a);
  283. #define REO(x) /* Her name is Reo, and she dances on the sands...sorry*/ \
  284.     addr=x();tbyte=ByteAt(addr);if(tbyte&128)flags|=CAR;else flags&=~CAR;\
  285.     tbyte=RAM[addr]=tbyte<<1;a^=tbyte;FlagsNZ(a);
  286. #define SKP(x) \
  287.     pc+=x;
  288. #define TEA(y) \
  289.     tbyte=RAM[y()]=a&x&ByteAt(pc+1);FlagsNZ(tbyte);
  290. #define TEX(y) \
  291.     tbyte=RAM[y()]=x&ByteAt(pc+1);FlagsNZ(tbyte);
  292. #define TEY(x) \
  293.     tbyte=RAM[x()]=y&ByteAt(pc+1);FlagsNZ(tbyte);
  294. #define XMA() \
  295.     a|=x&ImmediateByte();FlagsNZ(a);